
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>zookeeper集群之间如何通讯 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>zookeeper集群之间如何通讯 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Zookeeper集群中的节点分为哪三种角色？它们各自的主要职责是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zookeeper集群的节点分为三种角色：1. Leader：处理所有写请求，并协调集群中的事务。2. Follower：处理读请求，并从Leader获取事务信息，同时参与Leader选举。3. Observer：主要处理读请求，不参与Leader选举，但可以从Leader获取数据。</div>
          </div>
          <div class="card-source">来源: 1. 节点角色和通信</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">协议</div>
          <div class="card-question">ZAB协议在Zookeeper中扮演什么核心角色？它主要实现了哪两个关键功能？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">协议</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">ZAB（Zookeeper Atomic Broadcast）协议是Zookeeper的核心协议。它主要实现了两个关键功能：1. 全序广播，确保所有写操作在集群的所有节点上以相同的顺序应用，以实现一致性。2. Leader选举，确保集群中只有一个节点成为Leader。</div>
          </div>
          <div class="card-source">来源: 3.1 ZAB 协议</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Zookeeper集群是如何检测到某个节点发生故障的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zookeeper通过心跳机制来监测节点的健康状态。节点之间会发送心跳消息，如果某个节点的心跳消息丢失，其他节点会将其标记为故障，并可能触发Leader选举等恢复操作。</div>
          </div>
          <div class="card-source">来源: 4.1 故障检测</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">当Zookeeper集群中的Leader节点失效时，会发生什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当Leader节点失效时，集群会启动Leader选举过程，以选择一个新的Leader。这个过程确保了集群在发生故障后能够快速恢复服务。</div>
          </div>
          <div class="card-source">来源: 4.2 故障恢复</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">协议</div>
          <div class="card-question">Zookeeper使用什么协议来确保所有节点对事务的处理顺序保持一致？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">协议</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zookeeper使用一种称为“原子广播”（Atomic Broadcast）的协议来实现数据同步，该协议能确保所有节点对事务的顺序保持一致。</div>
          </div>
          <div class="card-source">来源: 2.2 节点间通信</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">当一个Follower节点启动或重新加入集群时，它如何与Leader节点进行数据同步？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Follower节点会从Leader获取最新的数据快照以加速恢复，然后回放自快照生成以来的所有事务日志，从而达到与Leader数据完全同步的状态。</div>
          </div>
          <div class="card-source">来源: 3.2 数据同步</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">为了优化网络性能，Zookeeper采用了哪两种主要技术手段？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zookeeper采用了两种主要技术来优化网络通信：1. 数据压缩：对网络传输的数据进行压缩，以减少带宽使用。2. 批量传输：支持将多个操作合并为一个批量请求进行传输，以减少网络开销和提高吞吐量。</div>
          </div>
          <div class="card-source">来源: 5. 网络通信优化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Zookeeper如何保障节点间通信的数据安全性，防止数据被窃听或篡改？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zookeeper支持使用TLS/SSL对通信进行加密。通过加密通信，可以确保数据在网络传输过程中的安全性，防止数据被窃听和篡改。</div>
          </div>
          <div class="card-source">来源: 6.1 TLS/SSL</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Observer角色与Follower角色在功能上的主要区别是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Observer和Follower都可以处理读请求并从Leader获取数据。主要区别在于，Follower节点会参与Leader的选举过程，而Observer节点不参与选举。</div>
          </div>
          <div class="card-source">来源: 1. 节点角色和通信</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
